/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jule.clases;

// imports necesarios
import java.util.Properties;
import javax.sql.DataSource;

//import schemacrawler.utility.datasource.PropertiesDataSource;

//import schemacrawler.crawl.SchemaCrawlerOptions;
//import schemacrawler.crawl.SchemaInfoLevel;
////import schemacrawler.schema.Column;
//import schemacrawler.schema.Schema;
//import schemacrawler.schema.Table;
//import schemacrawler.schema.View;
//import schemacrawler.utility.datasource.PropertiesDataSource;

/**
 *
 * @author Administrador
 */
public class dbUtil {

    public dbUtil() {
    }

    public static DataSource makeDataSourceMySql(String host, String database, String user, String password, String port) throws Exception {
//        final String datasourceName = database;
//
//        final Properties connectionProperties = new Properties();
//        connectionProperties.setProperty(datasourceName + ".driver", "org.gjt.mm.mysql.Driver");
//        connectionProperties.setProperty(datasourceName + ".url", "jdbc:mysql://" + host + ":" + port + "/" + database);
//        connectionProperties.setProperty(datasourceName + ".user", user);
//        connectionProperties.setProperty(datasourceName + ".password", password);
//
//        PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);
//        return prop;
            return null;
    }

    public static String testDataSourceMySql(String host, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "org.gjt.mm.mysql.Driver");
//            connectionProperties.setProperty(datasourceName + ".url", "jdbc:mysql://" + host + ":" + port + "/" + database);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);

            return "";
        } catch (Exception ex) {
            return ex.getMessage().toString() + ex.getStackTrace().toString();
        }

    }

    public static String testDataSourceSqlServer(String host, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
//            //connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ":" + port + ";databaseName=" + database);
//            // sql server 2005 uses dinamic ports so dont use 1433 port...
//            // remember to use instancies...
//            connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ";databaseName=" + database);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);

            return "";
        } catch (Exception ex) {
            return ex.getMessage().toString();
        }
    }

     
    public static DataSource MakeDataSourceSqlServer(String host, String database, String instance, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            //final net.sourceforge.jtds.jdbcx.JtdsDataSource datas;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
//            //connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ":" + port + ";databaseName=" + database);
//            // sql server 2005 uses dinamic ports so dont use 1433 port...
//            // remember to use instancies...
//             String url="";
//            url= "jdbc:sqlserver://" + host  ;
//            if (!instance.equals(""))
//                url = url + "\\" + instance;
//            url += ";databaseName=" + database;
//
//            connectionProperties.setProperty(datasourceName + ".url", url);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);
//
//            return prop;
            return null;
        } catch (Exception ex) {
            return null;
        }
    }


     public static String testDataSourceSqlServerJtds(String host, String instance, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "net.sourceforge.jtds.jdbc.Driver");
//            //connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ":" + port + ";databaseName=" + database);
//            // sql server 2005 uses dinamic ports so dont use 1433 port...
//            // remember to use instancies...
//            String url="";
//            url= "jdbc:jtds:sqlserver://" + host + "//" + database +";SelectMethod=cursor";
//            if (!instance.equals(""))
//                url = url + ";instance=" + instance;
//            connectionProperties.setProperty(datasourceName + ".url", url);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//            connectionProperties.setProperty(datasourceName + ".instance", instance);
//
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);
//            prop.getConnection();

            return "";
        } catch (Exception ex) {
            return ex.getMessage().toString();
        }
    }

     
    public static DataSource MakeDataSourceSqlServerJdts(String host, String instance, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "net.sourceforge.jtds.jdbc.Driver");
//            //connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ":" + port + ";databaseName=" + database);
//            // sql server 2005 uses dinamic ports so dont use 1433 port...
//            // remember to use instancies...
//            String url="";
//            url= "jdbc:jtds:sqlserver://" + host + "//" + database +";SelectMethod=cursor";
//            if (!instance.equals(""))
//                url = url + ";instance=" + instance;
//            connectionProperties.setProperty(datasourceName + ".url", url);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//            connectionProperties.setProperty(datasourceName + ".instance", instance);
//
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);
//
//            return prop;
            return null;
        } catch (Exception ex) {
            return null;
        }
    }

    public static String testDataSourceOdbc(String host, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "sun.jdbc.odbc.JdbcOdbcDriver");
//            connectionProperties.setProperty(datasourceName + ".url", "jdbc:odbc:" + database);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);

            return "";
        } catch (Exception ex) {
            return ex.getMessage().toString();
        }
    }

    public static DataSource MakeDataSourceOdbc(String host, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "sun.jdbc.odbc.JdbcOdbcDriver");
//            connectionProperties.setProperty(datasourceName + ".url", "jdbc:odbc:" + database);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);
//            return prop;
            return null;
        } catch (Exception ex) {
            return null;
        }
    }

    public static String testDataSourceSqlExpress(String host, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
//            //connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ":" + port + ";databaseName=" + database);
//            // sql server 2005 uses dinamic ports so dont use 1433 port...
//            // remember to use instancies...
//
//            connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ";databaseName=" + database);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);

            return "";
        } catch (Exception ex) {
            return ex.getMessage().toString();
        }
    }

    public static DataSource MakeDataSourceSqlExpress(String host, String database, String user, String password, String port) throws Exception {
        try {
//            final String datasourceName = database;
//            final Properties connectionProperties = new Properties();
//            connectionProperties.setProperty(datasourceName + ".driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
//            // remember to use instancies...
//
//            connectionProperties.setProperty(datasourceName + ".url", "jdbc:sqlserver://" + host + ";databaseName=" + database);
//            connectionProperties.setProperty(datasourceName + ".user", user);
//            connectionProperties.setProperty(datasourceName + ".password", password);
//
//            PropertiesDataSource prop = new PropertiesDataSource(connectionProperties, datasourceName);

//            return prop;
            return null;
        } catch (Exception ex) {
            return null;
        }
    }
}
